﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" Inherits="System.Web.Mvc.ViewPage<DeklaritModel.ProductDataSet>" %>

<%@ Import Namespace="System.Data" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">Create</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript">
        function menuAction(menuAction, formAction, ajax) {
            $("#MenuAction").val(menuAction);
            submitForm(formAction, ajax);
        }
        function submitForm(action, ajax) {
            var form = document.getElementById('ProductForm');
            if (action != '') {
                form.action = '/Product/' + action;
            }
            if(ajax){
				document.getElementById('ProductSubmit').click();
            }else{
				form.submit();
            }
        } 
        
        function onAjaxSuccess(){
			<%	bool? prompt = (bool?)ViewData["Prompt"];
				if (prompt ?? false) {   %>
            if(document.getElementById('PromptReturn') && document.getElementById('PromptReturn').value == 'true') {
                window.opener.<%= string.Format("{0}(document.getElementById('Prompt_{1}').value);", ViewData["PromptReturnFunction"], ViewData["PromptAttribute"]) %>
                window.close();
            }
			<%	}	%>
        }           
    </script>

    <form id="Form1" runat="server">
    <%	MVCApplication.Helpers.MenuHelper.AddMenuOptions(Menu1, (MVCApplication.Helpers.EnumMode)ViewData["Mode"], null, (bool?)ViewData["Prompt"], Page);	%>
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td id="cellMenu" class="toolbarMain">
                <asp:Menu SkinID="MenuSkin" Orientation="Horizontal" ID="Menu1" runat="server">
                    <Items>
                        <asp:MenuItem Text="Dummy"></asp:MenuItem>
                    </Items>
                </asp:Menu>
            </td>
        </tr>
    </table>

    <script type="text/javascript">
        var cellElement = document.getElementById("cellMenu");
        for (var i = 0; i < cellElement.childNodes.length; i++) {
            if (cellElement.childNodes[i].tagName == 'A') {
                cellElement.childNodes[i].style.display = 'none';
            }
        }
    </script>

    </form>
	<table width="100%">
		<tr>
			<td valign="top">
				<table width="100%" cellspacing="0" cellpadding="0" border="0">
					<tr class="formPageHeader">
						<td valign="top">
							<asp:Image runat="server" ID="LeftTop" SkinID="LeftTopForm" />
						</td>
						<td colspan="2">
							<label class="formHeader" >Product</label>
						</td>
						<td valign="top" align="right">
							<asp:Image runat="server" ID="RightTop" SkinID="RightTopForm" />
						</td>
					</tr>
					<tr class="formBody">
						<td colspan="4">
                            <% using (Ajax.BeginForm(null, null, new AjaxOptions { UpdateTargetId = "ProductDiv", OnSuccess = "onAjaxSuccess" }, new { id = "ProductForm", enctype = "multipart/form-data" }))
                               {	%>
                            <input id="ProductSubmit" type="submit" style="display:none" />
                            <div id="ProductDiv">
                                <% Html.RenderPartial("EditControl"); %>
                            </div>
                            <%  }	%>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
    <div class="divContactList-bottom">&nbsp;</div>

		<script type="text/javascript" language="JavaScript">
		
			onAjaxSuccess();
		</script>
		
						
						

</asp:Content>
